package com.object.oriented.exam.system2.controller;

import com.object.oriented.exam.system1.entity.Result;
import com.object.oriented.exam.system2.entity.ProblemProperty;
import com.object.oriented.exam.system2.service.ProblemPropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Lanh
 * @date 2023.06.18 19:10
 **/

@RestController
@RequestMapping("/problem_property")
public class ProblemPropertyController {

    @Autowired
    private ProblemPropertyService problemPropertyService;

    @PostMapping("/addProperty")
    public Result addProperty(@RequestBody ProblemProperty problemProperty){
        problemPropertyService.insert(problemProperty);
        return Result.success();
    }

    @PostMapping("/updateProperty")
    public Result updateProperty(@RequestBody ProblemProperty problemProperty){
        problemPropertyService.update(problemProperty);
        return Result.success();
    }

    @PostMapping("/deleteProperty")
    public Result deleteProperty(@RequestBody ProblemProperty problemProperty){
        problemPropertyService.delete(problemProperty);
        return Result.success();
    }

    @GetMapping("/{questionId}")
    public Result getProperty(@PathVariable Integer questionId){
        return problemPropertyService.getProperty(questionId);
    }

    @GetMapping("/listProperty")
    public Result listProperty(){
        return problemPropertyService.listProperty();
    }
}
